//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.utils.basehelper.distance;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
import java.util.function.Predicate;

public class DistinctByObjAttrUtils {
    public DistinctByObjAttrUtils() {
    }

    public static <T> Predicate<T> distinctByKey(Function<? super T, Object> keyExtractor) {
        Map<Object, Boolean> seen = new ConcurrentHashMap();
        return (object) -> {
            return keyExtractor.apply(object) != null && seen.putIfAbsent(keyExtractor.apply(object), Boolean.TRUE) == null;
        };
    }
}
